//
//  YDYSearchModel.m
//  DY_Bilibili
//
//  Created by 杨德勇 on 2016/10/24.
//  Copyright © 2016年 杨德勇. All rights reserved.
//

#import "YDYSearchModel.h"
#import "YDYNetWorkTool.h"
#import <NSObject+MJKeyValue.h>
@implementation YDYSearchModel

+(void)loadSearchWordsWithSuccess:(void (^)(NSArray *))success failure:(void (^)(NSError *))failure{
    [YDYNetWorkTool GET:@"http://s.search.bilibili.com/main/hotword?access_key=ec0f54fc369d8c104ee1068672975d6a&actionKey=appkey&appkey=27eb53fc9058f8c3" parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSArray *searches = responseObject[@"list"];
        NSMutableArray *searchModels = [NSMutableArray array];
        for (NSDictionary *dict in searches) {
            YDYSearchModel *searchModel = [YDYSearchModel mj_objectWithKeyValues:dict];
            [searchModels addObject:searchModel];
        }
        success(searchModels);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(error);
    }];
}

@end


